package demo.Thread;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/8/10-08-10-16:39
 * @Description：demo.Thread
 */
//女孩,负责花钱
public class Girl extends Thread{
    private Account account;
    public Girl(Account account, String name) {
        this.account = account; setName(name);
    }
    public void run() {
        //一直不停的花钱
        while(true){
            //随机钱数（看心情）
            int money = (int)(Math.random()*10000+1);
            //刷卡消费
            account.wit(money);
            try {//休息1秒后，继续花钱
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(this.getName() + "花费：" + money);
        }
    }
}

